/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: HYF
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using FriendStar.Code;
using FriendStar.Data;
using FriendStar.Domain.Entity.WareHouse;
using FriendStar.Domain.IRepository.WareHouse;
using FriendStar.Repository.Infrastructure;
using System.Collections.Generic;

namespace FriendStar.Repository.WareHouse
{
    public class CPK_11_DJ_StoRegisterRepository : RepositoryBase<CPK_11_DJ_StoRegisterEntity>, ICPK_11_DJ_StoRegisterRepository
    {
        public void SaveStoreCell(List<CPK_11_DJ_StoRegisterEntity> list)
        {
            string UseUnit = Configs.GetValue("UseUnit");
            string FFacNum = Configs.GetValue("FactoryFlag");
            string DocNum = GetDocumentNum.GetNum(UseUnit, FFacNum, "台账日期成品", OperatorProvider.Provider.GetCurrent().UserCode, "", "临时");
            using (var db = new RepositoryBase().BeginTrans())
            {
                try
                {
                    #region 执行
                    foreach (CPK_11_DJ_StoRegisterEntity item in list)
                    {
                        var obj = new
                        {
                            UseUnit = UseUnit,
                            FFacNum = FFacNum,
                            FRegisterID = item.FRegisterID,
                            FProductionNO = item.FProductionNO,
                            FProCompanyNO = item.FProCompanyNO,
                            FProductionTypeNO = item.FProductionTypeNO,
                            FQuantity = item.FQuantity,
                            FContainerNO = item.FContainerNO,
                            FContent = item.FContent,
                            FPalletNO = item.FPalletNO,
                            FPalletQuantity = item.FPalletQuantity,
                            FPalletContent = item.FPalletContent,
                            FAccountDate = DocNum,
                            UserNO = item.FCreateBy
                        };
                        db.ExecuteStoredProcedure<string>("Pro_StoreCell", obj);
                    }
                    #endregion 执行
                }
                catch (System.Exception ex)
                {
                    db.RollBack();
                    throw ex;
                }
            }
        }
    }
}
